{extend name='base'}
{block name='content'}
    <!--页面主要内容-->
<!--    hdjs-->
<script>
  window.hdjs={
    //组件目录必须绝对路径
    base : '/static/hdjs',
    //上传文件后台地址
    uploader : '{:url("admin/upload/upload")}',
    //获取文件列表的后台地址
    filesLists : '/filesLists.php?',
    //require.js配置项（可为空）
    requireJs:{paths:{},shim:{}},
  };
</script>
<script src="__STATIC__/hdjs/require.js"></script>
<script src="__STATIC__/hdjs/config.js"></script>
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-header">
                <h4>课程添加</h4>
              </div>
              <div class="card-body">
                
                <form action="#!" method="post" class="row">
                  <div class="form-group col-md-12">
                    <label>课程名称</label>
                    <input type="text" class="form-control" name="pro_name" value="" required placeholder="请输入课程名称" />
                  </div>
                  <div class="form-group col-md-12">
                    <label>课程作者</label>
                    <input type="text" class="form-control"  name="pro_author" required value="" placeholder="请输入作者" />
                  </div>
                  <div class="form-group col-md-12">
                    <label>课程排序</label>
                    <input type="number" class="form-control" name="pro_sort" required value="10" placeholder="请输入课程排序"/>
                  </div>
                  <div class="form-group col-md-12" id="thumb-form">
                    <label>缩略图</label><br>
                    <input type="text" class="form-control" id="thumb"  style="display: none" name="pro_thumb" value="" />
                    <button type="button" class="layui-btn" id="upimg">
                      <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                  </div>
                  <div class="form-group col-md-12" >
                    <label>课程描述</label>
                    <textarea id="content" style="height: 300px;border: none" name="pro_content" ></textarea>
                  </div>
                  <div class="form-group col-md-12">
                    <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确 定</button>
                  </div>
                </form>
       
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
<script>
  require(['hdjs'], function (hdjs) {
    hdjs.simditor({
      textarea: $('#content'),
      upload: {
        url: '{:url("admin/upload/upload")}',//后台上传地址
        fileKey: 'file'
      }
    })
  })
</script>
<script>
  layui.use('upload', function(){
    var upload = layui.upload;
    //执行实例
    var uploadInst = upload.render({
      elem: '#upimg' //绑定元素
      ,url: '{:url("admin/upload/uploadthumb")}' //上传接口
      ,accept: 'images' //允许上传的文件类型
      ,size: 7000 //最大允许上传的文件大小
      ,done: function(res){
        if(res.code==0){
          layer.msg('上传成功', {icon: 1});
          $("#thumb").val(res.data.src);
          $("#thumb").css("display","block");
        }else {
          layer.msg(res.msg, {icon: 2});
        }

      }
      ,error: function(){
        //请求异常回调
      }
    });
  });
</script>
{/block}